package com.znk.aop.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Aspect
@Component
public class CalAspect {

    @Before("execution(public int com.znk.aop.impl.CalImpl.*(..))")
    public void before(JoinPoint joinPoint) {
        String name = joinPoint.getSignature().getName();
        System.out.println(name + "方法的参数是：" + Arrays.toString(joinPoint.getArgs()));
    }

    @AfterReturning(value = "execution(public int com.znk.aop.impl.CalImpl.*(..))",returning = "result")
    public void afterReturning(JoinPoint joinPoint,int result) {
        String name = joinPoint.getSignature().getName();
        System.out.println(name + "方法的结果是：" + result);
    }

}
